package ch.sfug.sequence {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	import ch.sfug.sequence.ISequenceChild;	

	/**
	 * @author mich
	 */
	public class Break extends EventDispatcher implements ISequenceChild {

		private var delay:Timer;

		public function Break( ms:Number ) {
			super();
			delay = new Timer( ms, 1 );
			delay.addEventListener(TimerEvent.TIMER_COMPLETE, delegate );
		}
		
		/**
		 * delegates the timer event
		 */
		private function delegate( e:Event ):void {
			dispatchEvent( new Event( Event.COMPLETE ) );
		}
		
		public function hasToWait():Boolean {
			return true;
		}
		
		public function execute():void {
			delay.start();
		}

		public function stop():void {
			delay.stop();
		}
		
		public function setArguments(args:Array):void {
		}
	}
}
